#!/bin/bash
# Start HBase
#  1) thrift API/Web UI
#  2) hbase master (which runs the local region server)

logs_dir=/data/logs

# Prepare environment
/opt/replace-hostname
mkdir -p $logs_dir /data/hbase /data/run

# Thrift server (background)
# Ports: 9090 API and 9095 UI
echo "hbase thrift start logging to $logs_dir/hbase-thrift.log"
hbase thrift start > $logs_dir/hbase-thrift.log 2>&1 &

# REST server (background)
# Ports: 8080 API
echo "hbase rest start logging to $logs_dir/hbase-rest.log"
hbase rest start > $logs_dir/hbase-rest.log 2>&1 &

# Master server (Foreground) that also starts the region server
# Ports: Master: 16000 API, 16010 UI; 2181 ZK;  Region: 16020 API, 16030 UI
echo "hbase master start logging to $logs_dir/hbase-master.log"
exec hbase master start 2>&1 | tee $logs_dir/hbase-master.log
